<template>
	<view class="empty" style="margin-top: 300rpx;" v-if="list.length == 0">
		<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
		</u-empty>
	</view>
	<view class="" v-else>
		<view class="column min30 pad20 bg-f rad2" v-for="(item, index) in list" :key="index"
			@click="$jump.nav('/indexpackage/notice?id=' + item.id)">
			<view class="row">
				<view class="head_title omit1">
					<text class="head_title_size">{{ item.title }}</text>
				</view>
				<view class="minau minright0">
					<text class="time_size">{{ $com.format(item.create_time, 'yyyy-MM-dd') }}</text>
				</view>
			</view>
			<!-- <view class="content"><text class="time_size">{{ item.content }}</text></view> -->
		</view>
		<view style="margin-top: 50rpx;"><u-loadmore :status="status" /></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				list: []
			}
		},
		onShow() {
			this.getNotice()
		},
		onReachBottom() {
			if (this.page < 0) return;
			this.status = 'loading';
			this.page = ++this.page
			this.getNotice()
			setTimeout(() => {
				console.log(this.loadmore);
				if (this.loadmore.length == 0) this.status = 'nomore';
				else this.status = 'loading';
			}, 1000)
		},
		methods: {
			async getNotice() {
				let {
					code,
					data,
					msg
				} = await this.$com.fetchGet('AppletHome/bulletin', {
					page: this.page
				});
				if (code == 1) {
					if (this.page != 1) {
						this.loadmore = data.items
						for (var i = 0; i < data.items.length; i++) {
							this.list.push(data.items[i]); // 加载的数据追加在上一页后面
						}
					} else {
						this.loadmore = data.items
						this.list = data.items
					}
				} else {
					console.log(msg);
				}
			},

		}
	}
</script>

<style>
	page {
		background-color: #f5f5f5;
	}
</style>

<style scoped lang="less">
	.bg-f {
		background-color: #fff;
	}

	.head_title {
		max-width: 60%;

		.head_title_size {
			font-size: 30rpx;
			font-weight: 600;
			color: #333;
		}
	}

	.time_size {
		font-size: 26rpx;
		font-weight: 400;
		color: #999;
	}

	.content {
		font-size: 28rpx;
		font-weight: 400;
		color: #333;
		width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
	}
</style>